package com.vvlive.caibao.smartcity.ui;

import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.vvlive.caibao.smartcity.base.BaseActivity;
import com.vvlive.caibao.smartcity.bean.GoOutInfo;
import com.vvlive.caibao.smartcity.bean.MyLocationBean;
import com.vvlive.caibao.smartcity.utils.MyLocationUtil;
import com.vvlive.caibao.smartcity.view.CommonActionBar;

import org.kymjs.kjframe.ui.BindView;

import smartcity.vvlive.caibao.com.smartc.R;

/**
 * Created by android on 2015/7/17.
 */
public class ActivityGoRegister extends BaseActivity implements MyLocationUtil.GetMyLocation{
    @BindView(id= R.id.go_input)
    private EditText GO_input;
    @BindView(id= R.id.go_dingwei)
    private ImageButton Go_dingwei_btn;
    @BindView(id= R.id.go_show_adress)
    private TextView Go_show_adress;
    @BindView(id= R.id.go_submit,click = true)
    private Button GO_submit;
    @BindView(id= R.id.go_about,click = true)
    private TextView Go_about;
    @BindView(id = R.id.go_adress ,click = true)
    private RelativeLayout Go_adress;

    private String Adress;
    private String info;


    @Override
    protected int getContentViewRes() {
        return R.layout.go_register;
    }

    @Override
    public void initWidget() {
        super.initWidget();
        CommonActionBar bar = getCommonActionBar();
        bar.setTitle("外出登记");
        bar.setMoreVisible(false);
    }

    @Override
    public void widgetClick(View v) {
        super.widgetClick(v);
        switch (v.getId()){
            case R.id.go_adress:
                dingweiInfo();
                break;
            case R.id.go_submit:
                SubimitInfo();
                break;
            case R.id.go_about:
                alert("外出登记是没有工资的！");
                break;
            default:
                break;
        }
    }

    private void dingweiInfo(){
        new MyLocationUtil(this,this);
    }
    private void SubimitInfo(){
        info = GO_input.getText().toString();
        if (Judge()){
            alert(new GoOutInfo(Adress,info));

        }else {
            alert("请完善外出登记的信息");
        }
    }
    private boolean Judge(){
        return !TextUtils.isEmpty(Adress)&&!TextUtils.isEmpty(info)?true:false;
    }


    @Override
    public void MyLocation(MyLocationBean myLocationBean) {
        //Adress =  myLocationBean.getDes().toString();
        Adress = myLocationBean.getRoad().toString();
        Log.e("zhi",Adress+">>>>>>");
        Go_show_adress.setText(Adress);
    }
}
